home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 3 of 3 / CHAPTE10 / GETADSTA / LINE.C < prev    next >
C/C++ Source or Header  |  1996-04-28  |  26KB  |  790 lines

  1.  
  2. #include <windows.h> 
  3. #include <windowsx.h> 
  4. #include "line.h" 
  5. #include "tapi.h"
  6.  
  7. #define BUFSIZE 256
  8. #define APIHIVERSION     0x00010028    /* 1.40 */
  9. #define APILOWVERSION    0x00010000    /* 1.0 */
  10. #define EXTHIVERSION     0x00010005    /* 1.5 */
  11. #define EXTLOWVERSION    0x00000009    /* 0.9 */ 
  12. #define OWNER        0
  13. #define MONITOR      1
  14. #define MAX_CALL        3
  15. #define MAX_LINE        2
  16.  
  17.  
  18. #if defined (WIN32)
  19.     #define IS_WIN32 TRUE
  20. #else
  21.     #define IS_WIN32 FALSE
  22. #endif
  23.  
  24. #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
  25. #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
  26. #define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
  27.  
  28. LPCTSTR lpszAppName = "lineGetAddressStatus";
  29. LPCTSTR lpszTitle   = "lineGetAddressStatus"; 
  30.  
  31. HINSTANCE hInst;   // current instance
  32. HWND hWnd;         // parent window handle
  33. HWND hListWnd;     // listbox
  34. HDC  hdc;
  35. TEXTMETRIC  tm ;
  36.  
  37. BOOL RegisterWin95( CONST WNDCLASS* lpwc );
  38.  
  39.  
  40. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  41.                       LPTSTR lpCmdLine, int nCmdShow)
  42. {
  43.    MSG      msg;
  44.    WNDCLASS wc;
  45.  
  46.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  47.    wc.lpfnWndProc   = (WNDPROC)WndProc;       
  48.    wc.cbClsExtra    = 0;                      
  49.    wc.cbWndExtra    = 0;                      
  50.    wc.hInstance     = hInstance;              
  51.    wc.hIcon         = LoadIcon (hInstance, lpszAppName); 
  52.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  53.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  54.    wc.lpszMenuName  = lpszAppName;              
  55.    wc.lpszClassName = lpszAppName;              
  56.  
  57.    if ( IS_WIN95 )
  58.    {
  59.       if ( !RegisterWin95( &wc ) )
  60.          return( FALSE );
  61.    }
  62.    else if ( !RegisterClass( &wc ) )
  63.       return( FALSE );
  64.  
  65.    hInst = hInstance; 
  66.  
  67.    hWnd = CreateWindow( lpszAppName, 
  68.                         lpszTitle,    
  69.                         WS_OVERLAPPEDWINDOW, 
  70.                         CW_USEDEFAULT, 0, 
  71.                         CW_USEDEFAULT, 0,  
  72.                         NULL,              
  73.                         NULL,              
  74.                         hInstance,         
  75.                         NULL               
  76.                       );
  77.  
  78.    if ( !hWnd ) 
  79.       return( FALSE );
  80.  
  81.    ShowWindow( hWnd, nCmdShow ); 
  82.    UpdateWindow( hWnd );         
  83.  
  84.    while( GetMessage( &msg, NULL, 0, 0) )   
  85.    {
  86.       TranslateMessage( &msg ); 
  87.       DispatchMessage( &msg );  
  88.    }
  89.  
  90.    return( msg.wParam ); 
  91. }
  92.  
  93.  
  94. BOOL RegisterWin95( CONST WNDCLASS* lpwc )
  95. {
  96.     WNDCLASSEX wcex;
  97.  
  98.    wcex.style         = lpwc->style;
  99.    wcex.lpfnWndProc   = lpwc->lpfnWndProc;
  100.    wcex.cbClsExtra    = lpwc->cbClsExtra;
  101.    wcex.cbWndExtra    = lpwc->cbWndExtra;
  102.    wcex.hInstance     = lpwc->hInstance;
  103.    wcex.hIcon         = lpwc->hIcon;
  104.    wcex.hCursor       = lpwc->hCursor;
  105.    wcex.hbrBackground = lpwc->hbrBackground;
  106.    wcex.lpszMenuName  = lpwc->lpszMenuName;
  107.    wcex.lpszClassName = lpwc->lpszClassName;
  108.  
  109.    // Added elements for Windows 95.
  110.    //...............................
  111.    wcex.cbSize = sizeof(WNDCLASSEX);
  112.    wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
  113.                             IMAGE_ICON, 16, 16,
  114.                             LR_DEFAULTCOLOR );
  115.             
  116.    return RegisterClassEx( &wcex );
  117. }
  118.  
  119. #define CONFCALL    1
  120. #define CONSULT      2
  121.  
  122. enum CallState
  123. {
  124.     Idle,
  125.     Offering,
  126.     Accepted,
  127.     Dialtone,
  128.     Dialing,
  129.     Ringback,
  130.     Busy,
  131.     Special,
  132.     Connected,
  133.     Proceeding,
  134.     Conferenced,
  135.     Onholdconf,
  136.     Disconnected,
  137.     Unknown
  138. };
  139.  
  140. typedef struct tagMYINFO      // general application information
  141. {
  142.     HLINEAPP lineApp;         // instance handle TAPI gives back to us                                                                              through lineInitialize()
  143.     DWORD dwNumDevices;       // number of available devices
  144.     DWORD dwAPIVersion;       // API version the line supports
  145.      DWORD dwExtVersion;           // extended version
  146.     char szLocation[128];     // location        
  147.      char szCallingCard[128];  // calling card being used
  148.     char szAreaCode[4];       // area code       
  149.     char szCountry[128];      // calling card being used
  150. } MYINFO;
  151.  
  152. typedef struct tagLINEINFO  // information on an open line
  153. {
  154.     DWORD dwNumAddress;     // number of available addresses on the line 
  155.     HLINE hLine;            // handle to the line as returned by lineOpen 
  156.      DWORD dwLineID;         // the line ID of this line
  157.     char  szLineName[128];  // the line's name 
  158.  
  159. } MYLINEINFO;
  160.  
  161. typedef struct tagMYCALLINFO  //information on a call                     
  162. {
  163.     
  164. DWORD       eCallState;    // TAPI's line call State, set as user-defined enums
  165. DWORD      dwRequestID;   // requestID returned by async TAPI functions lineMakeCall/lineDropCall
  166. DWORD      dwAddressID;   // the originating address ID of the call being made 
  167. LPCSTR     lpszAddress;    
  168. HLINE     hLine;         // handle to the line 
  169. HCALL        hCall;         // handle to the call 
  170.    
  171. char szDialString[TAPIMAXDESTADDRESSSIZE];  //phone number being dialed
  172. char szDialStringOriginal[TAPIMAXDESTADDRESSSIZE];
  173. char szDialStringCanonical[TAPIMAXDESTADDRESSSIZE];
  174. char szCalledParty[TAPIMAXCALLEDPARTYSIZE]; // name of the party
  175. DWORD dwTranslateResults;
  176.         
  177. } MYCALLINFO;
  178.  
  179. enum CallAction     // Declare enum type CallAction (used in lineSetAppSpecific)
  180. {
  181.    HOLD,            // hold the call
  182.    TRANSFER,        // transfer the call
  183.    REDIRECT,        // redirect the call
  184.    DROP,            // drop the call
  185.    PARK             // park the call
  186. }; 
  187.  
  188. MYINFO myInfo;          //instance of MYINFO structure
  189. MYLINEINFO myLineInfo[MAX_LINE];  //instance of MYLINEINFO structure
  190. MYCALLINFO myCallInfo[MAX_CALL]; //array of MYCALLINFO strcuture
  191.  
  192. LONG lRet;        //return code
  193. char buf[BUFSIZE];    // buffer for debug message
  194.  
  195. DWORD dwLineID = 0;
  196. DWORD i;
  197. LINEEXTENSIONID        ext_id;
  198. LINEDEVCAPS            *plineDevCaps;
  199. LINEADDRESSCAPS        *plineAddressCaps;
  200. LINEADDRESSSTATUS     *plineAddressStat;
  201. LINECALLINFO            *plineCallInfo;
  202. LINECALLSTATUS         *plineCallStatus;
  203. LINECALLLIST            *plineCallList;
  204. LINEDEVSTATUS           *plineDevStatus;
  205. LINETRANSLATECAPS       *plineTranslateCaps;
  206. LINETRANSLATEOUTPUT  *plineTranslateOutput;
  207. LINECALLPARAMS           *plineCallParams;
  208. LINEDEVSTATUS           *plineDevStatus;
  209. LINEFORWARDLIST        *plineForwardList;
  210. LINETRANSLATECAPS       *plineTranslateCaps;
  211. LINEREQMAKECALL       lineReqMakeCall;
  212. VARSTRING               *pDeviceConfig;
  213. VARSTRING               *pDeviceId;
  214. VARSTRING               *pNonDirAddress;
  215.  
  216. LPLINELOCATIONENTRY  lineLocEntry;
  217. LPLINECARDENTRY        lineCardEntry;
  218. LINECOUNTRYLIST         *plineCountryList;
  219. LPLINECOUNTRYENTRY   lineCE;
  220.  
  221. LPSTR                lpData;
  222.  
  223. HICON                hIcon = NULL;        //used in lineGetID();
  224. DWORD                dwNumRings;    //used in lineGetNumRings();
  225. HCALL                hConsultCall; //handle to consultation linePrepareAddToConference, SetupConference
  226. HCALL                hConfCall; //handle to consultation linePrepareAddToConference, SetupConference   
  227. HCALL                hParkedCall;
  228.  
  229. DWORD                dwCompletionID;  //used in lineCompleteCall()
  230.  
  231. char                szName[128];
  232. char                szNumber[128];
  233. char                szDigits[128];
  234. char                szDevConfig[128];
  235.  
  236. LONG lRet;
  237. char buf[BUFSIZE];
  238.  
  239. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  240. {
  241.    switch( uMsg )
  242.    {
  243.       case WM_COMMAND :
  244.          switch( LOWORD( wParam ) )
  245.          {
  246.             case IDM_RUN :
  247.                DialogBox( hInst, "IDD_DIALNUM", hWnd, (DLGPROC)Dial );
  248.                break;
  249.  
  250.             case IDM_GETADDSTAT :
  251.                //query address caps only if we have a connected call
  252.                //................................................      
  253.                if (myCallInfo[0].eCallState != Connected)
  254.                {
  255.                   MessageBox (hWnd, "Place your call in the connected state and try again...", "", MB_OK);
  256.                   break;
  257.                }
  258.  
  259.                //only check status if we have a connected call
  260.                //.........................................
  261.                if (myCallInfo[0].eCallState != Connected)
  262.                   break;   
  263.                plineAddressStat = (LINEADDRESSSTATUS*) calloc (1,  
  264.                                    sizeof(LINEADDRESSSTATUS) +1000);
  265.                plineAddressStat->dwTotalSize = sizeof(LINEADDRESSSTATUS)+1000;
  266.                
  267.                // get address status info
  268.                //..................................
  269.                lRet = lineGetAddressStatus( myLineInfo[0].hLine,
  270.                                   myCallInfo[0].dwAddressID ,plineAddressStat);
  271.                
  272.                if (lRet == 0)
  273.                {
  274.                   wsprintf (buf, "lineGetAddressStatus succeeded!");
  275.                   if (plineAddressStat->dwAddressFeatures & 
  276.                                                        LINEADDRFEATURE_FORWARD)
  277.                   {
  278.                      wsprintf (buf, "This address can be forwarded!"); 
  279.                           SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  280.                   }
  281.                   else
  282.                   {
  283.                      wsprintf (buf, "This address can not be forwarded!"); 
  284.                           SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  285.                   }
  286.                              
  287.                }
  288.                else 
  289.                {
  290.                   wsprintf ( buf,"lineGetAddressStatus failed, err=x%lx",  
  291.                              lRet);
  292.                   lineError(lRet);
  293.                }
  294.                free (plineAddressStat);
  295.                break;
  296.  
  297.             
  298.             case IDM_ABOUT :
  299.             {
  300.                 DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
  301.                break;
  302.             }
  303.  
  304.             case IDM_EXIT :
  305.             {
  306.                for (i = 0; i < myInfo.dwNumDevices; i++)
  307.                        lineClose(myLineInfo[i].hLine);
  308.                     lineShutdown(myInfo.lineApp);
  309.                DestroyWindow( hWnd );
  310.                break;
  311.             }
  312.             }                  
  313.                  
  314.          break;
  315.  
  316.       case WM_CREATE :
  317.       {
  318.          hdc = GetDC (hWnd) ;
  319.          GetTextMetrics (hdc, &tm) ;
  320.          ReleaseDC (hWnd, hdc) ;
  321.  
  322.          hListWnd = CreateWindowEx( 0, "listbox", 
  323.                         " ",    
  324.                         WS_CHILD | WS_VISIBLE,  
  325.                         tm.tmAveCharWidth, tm.tmHeight * 3, 
  326.                         tm.tmAveCharWidth * 16 +
  327.                                    GetSystemMetrics (SM_CXVSCROLL), 
  328.                         tm.tmHeight * 5,  
  329.                         hWnd,              
  330.                         NULL,              
  331.                         hInst,         
  332.                         NULL               
  333.                         );
  334.  
  335.          
  336.          //lineInitialize
  337.             //...............................................
  338.          lRet = lineInitialize(&myInfo.lineApp, hInst, lineCallback, NULL, &myInfo.dwNumDevices);
  339.          if (lRet == 0) 
  340.          {
  341.             wsprintf (buf, "lineInitialize suceeded!");
  342.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  343.            }
  344.          else 
  345.           {
  346.                wsprintf ( buf,"lineInitialize failed, err=x%lx",lRet);
  347.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  348.                lineError(lRet);
  349.                break;
  350.          }                    
  351.          
  352.          //lineNegotiateAPIVersion
  353.           //...............................................
  354.          lRet = lineNegotiateAPIVersion(myInfo.lineApp, 0, APILOWVERSION, APIHIVERSION, 
  355.                                            &myInfo.dwAPIVersion, &ext_id);
  356.          if (lRet == 0)                        
  357.          {
  358.             wsprintf (buf, "lineNegotiateAPIVersion suceeded!");
  359.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  360.          }
  361.          else 
  362.           {
  363.                wsprintf (buf, "lineNegotiateAPIVersion failed, err=x%lx",
  364.                            lRet);
  365.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  366.                lineError(lRet);
  367.                lineShutdown (myInfo.lineApp);
  368.             break;
  369.          }
  370.  
  371.           //lineNegotiateExtVersion
  372.           //...............................................
  373.          lRet = lineNegotiateExtVersion(myInfo.lineApp, 0, myInfo.dwAPIVersion, EXTLOWVERSION, 
  374.                                            EXTHIVERSION, &myInfo.dwExtVersion);
  375.          if (lRet == 0)                        
  376.          {
  377.             wsprintf (buf, "lineNegotiateExtVersion suceeded!");
  378.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  379.  
  380.          }
  381.           else 
  382.           {
  383.                wsprintf (buf, "lineNegotiateExtVersion failed, err=x%lx",
  384.                      lRet);
  385.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  386.               lineError(lRet);
  387.       
  388.          }
  389.  
  390.           //lineGetDevCaps
  391.           //for each line device, get capabilities until we find one that supports
  392.          //interactive voice 
  393.           //...............................................
  394.          plineDevCaps = (LINEDEVCAPS *) calloc (1, sizeof(LINEDEVCAPS)+1000);
  395.          plineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS) + 1000;
  396.          for (i = 0; i < myInfo.dwNumDevices; i++)
  397.          {
  398.             lineGetDevCaps(myInfo.lineApp, i, myInfo.dwAPIVersion, 0, plineDevCaps);
  399.             if (plineDevCaps->dwMediaModes & LINEMEDIAMODE_INTERACTIVEVOICE) 
  400.             {
  401.                
  402.                myLineInfo[i].dwNumAddress = plineDevCaps->dwNumAddresses;
  403.                   myLineInfo[i].dwLineID = i;
  404.                    if (plineDevCaps->dwLineNameSize > 0)
  405.                           strcpy(myLineInfo[i].szLineName,((LPSTR)(plineDevCaps)+plineDevCaps->dwLineNameOffset));
  406.              }
  407.           }
  408.  
  409.          //lineOpen
  410.           //................................................................
  411.           lRet = lineOpen(myInfo.lineApp,myLineInfo[OWNER].dwLineID,&myLineInfo[OWNER].hLine,
  412.                            myInfo.dwAPIVersion,0,(DWORD)lineCallback, LINECALLPRIVILEGE_NONE,
  413.                             LINEMEDIAMODE_DATAMODEM, NULL);
  414.           if (lRet == 0)
  415.           {
  416.             wsprintf (buf, "lineOpen suceeded!");
  417.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;         }
  418.            else 
  419.            {
  420.                wsprintf ( buf,"lineOpen failed, err=x%lx", lRet);
  421.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  422.                lineError(lRet);
  423.           }
  424.        
  425.          break;
  426.       }
  427.       
  428.       case WM_SIZE:
  429.           MoveWindow(hListWnd,0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
  430.          break;
  431.  
  432.       case WM_DESTROY :
  433.               PostQuitMessage(0);
  434.               break;
  435.  
  436.       default :
  437.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  438.    }
  439.  
  440.    return( 0L );
  441. }
  442.  
  443.  
  444.  
  445.  
  446. /****************************************************************************
  447.     FUNCTION: lineCallback
  448.     PURPOSE:  callback function handles line events
  449. ****************************************************************************/
  450. LRESULT CALLBACK lineCallback (DWORD dwDevice, DWORD dwMsg,
  451.                                        DWORD dwCallbackInst, DWORD dwParam1,
  452.                                        DWORD dwParam2,DWORD dwParam3)
  453. {
  454.    switch (dwMsg)
  455.    {
  456.       case LINE_CALLSTATE:
  457.        {
  458.             for (i = 0; i < MAX_CALL; i++)
  459.            {
  460.                 if (dwDevice = (DWORD) myCallInfo[i].hCall) 
  461.                  switch (dwParam1)
  462.                  {
  463.                     case LINECALLSTATE_IDLE:
  464.                         myCallInfo[i].eCallState = Idle;
  465.                   break;
  466.                     
  467.                     case LINECALLSTATE_OFFERING:
  468.                   myCallInfo[i].eCallState = Offering;
  469.                   break;
  470.                                    
  471.                     case LINECALLSTATE_ACCEPTED:
  472.                         myCallInfo[i].eCallState = Accepted;
  473.                         break;
  474.                     
  475.                     case LINECALLSTATE_DIALTONE:
  476.                         myCallInfo[i].eCallState = Dialtone;
  477.                   break;
  478.                     
  479.                     case LINECALLSTATE_DIALING:
  480.                         myCallInfo[i].eCallState = Dialing;
  481.                         break;
  482.                   
  483.                   case LINECALLSTATE_RINGBACK:
  484.                         myCallInfo[i].eCallState = Ringback;
  485.                         break;
  486.             
  487.                     case LINECALLSTATE_BUSY:
  488.                         myCallInfo[i].eCallState = Busy;
  489.                         break;
  490.             
  491.                     case LINECALLSTATE_SPECIALINFO:
  492.                         myCallInfo[i].eCallState = Special;
  493.                        break;
  494.             
  495.                     case LINECALLSTATE_CONNECTED:
  496.                        myCallInfo[i].eCallState = Connected;
  497.                   break;
  498.  
  499.                     case LINECALLSTATE_PROCEEDING:
  500.                         myCallInfo[i].eCallState = Proceeding;
  501.                        break;
  502.             
  503.                     case LINECALLSTATE_CONFERENCED:
  504.                         myCallInfo[i].eCallState = Conferenced;
  505.                        break;
  506.             
  507.                     case LINECALLSTATE_ONHOLDPENDCONF:
  508.                         break;
  509.                 
  510.                case LINECALLSTATE_DISCONNECTED:
  511.                         myCallInfo[i].eCallState = Disconnected;
  512.                        break;
  513.             
  514.                     case LINECALLSTATE_UNKNOWN:
  515.                         myCallInfo[i].eCallState = Unknown;
  516.                        break;
  517.        
  518.              }
  519.           }
  520.        }
  521.  
  522.        case LINE_MONITORMEDIA:
  523.            break;
  524.  
  525.        case LINE_MONITORDIGITS:
  526.           break;
  527.  
  528.          case LINE_MONITORTONE:
  529.           break;
  530.    
  531.        //error handling for functions completed asynchronously
  532.         //.....................................................
  533.        case LINE_REPLY:
  534.         {
  535.             for (i = 0; i < MAX_CALL; i++)
  536.            {
  537.                 if (dwParam1 = myCallInfo[i].dwRequestID)
  538.                {
  539.                    if (dwParam2 != 0)
  540.                    {
  541.                        lineError((LONG) dwParam2);
  542.                        break;
  543.                    }
  544.                }
  545.            }
  546.         break;
  547.         }
  548.  
  549.         case LINE_GENERATE:
  550.           break;
  551.      
  552.        case LINE_REQUEST:
  553.          break;
  554.  
  555.         case LINE_GATHERDIGITS:
  556.            break;
  557.    }
  558.  
  559.    return (TRUE);
  560.  
  561.  
  562. /****************************************************************************
  563.     FUNCTION: lineError
  564.     PURPOSE:  line error messages
  565. ****************************************************************************/
  566. void lineError (LONG lrc)
  567. {
  568.  switch (lrc) {
  569.     case LINEERR_INVALAPPHANDLE:
  570.        MessageBox (hWnd, "Invalid app handle.", "", MB_OK);
  571.        break;
  572.     case LINEERR_BADDEVICEID:
  573.        MessageBox (hWnd,"The specified line device ID is out of range.", "", 
  574.                    MB_OK);
  575.        break;
  576.     case LINEERR_INCOMPATIBLEAPIVERSION:
  577.        MessageBox (hWnd, "Incompatible API version.", "", MB_OK);
  578.        break;
  579.     
  580.     case LINEERR_ADDRESSBLOCKED:
  581.        MessageBox (hWnd, "Address was blocked.", "", MB_OK);
  582.        break;
  583.  
  584.     case LINEERR_BEARERMODEUNAVAIL:
  585.        MessageBox (hWnd, "Bearer Mode Unavailable.", "", MB_OK);
  586.        break;
  587.  
  588.     case LINEERR_CALLUNAVAIL:
  589.        MessageBox (hWnd, "Call appearances in use..", "", MB_OK);
  590.        break;
  591.  
  592.     case LINEERR_INUSE:
  593.        MessageBox (hWnd, "Line in Use.", "", MB_OK);
  594.        break;
  595.     
  596.     case LINEERR_INVALADDRESS:
  597.        MessageBox (hWnd, "Invalid Address.", "", MB_OK);
  598.        break;
  599.  
  600.     case LINEERR_INVALADDRESSID:
  601.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  602.        break;
  603.  
  604.     case LINEERR_INVALCALLPARAMS:
  605.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  606.        break;
  607.      
  608.     case LINEERR_INCOMPATIBLEEXTVERSION:
  609.        MessageBox (hWnd, "Incompatible extension version.","", MB_OK);
  610.        break;
  611.     case LINEERR_NOMEM:
  612.        MessageBox (hWnd, "No memory","", MB_OK);
  613.        break;
  614.     case LINEERR_NODRIVER:
  615.        MessageBox (hWnd, "No driver loaded", "", MB_OK);
  616.        break;
  617.     case LINEERR_RESOURCEUNAVAIL:
  618.        MessageBox (hWnd, "Resource overcommittment", "", MB_OK);
  619.        break;
  620.     case LINEERR_INVALPRIVSELECT:
  621.        MessageBox (hWnd, "Requested invalid priviledges", "", MB_OK);
  622.        break;
  623.     case LINEERR_INVALMEDIAMODE:
  624.        MessageBox (hWnd, "Requested invalid media mode", "", MB_OK);
  625.        break;
  626.     case LINEERR_LINEMAPPERFAILED:
  627.        MessageBox (hWnd, "Line mapper failed", "", MB_OK);
  628.        break;
  629.     case LINEERR_INVALPOINTER:
  630.        MessageBox (hWnd, "The specified pointer parameter is invalid.",
  631.                    "", MB_OK);
  632.        break;
  633.     case LINEERR_OPERATIONFAILED:
  634.        MessageBox (hWnd, "Operation failed.", "", MB_OK);
  635.        break;
  636.     case LINEERR_INVALLINEHANDLE:
  637.        MessageBox (hWnd, "Invalid line handle", "", MB_OK);
  638.        break;
  639.     case LINEERR_INVALCALLHANDLE:
  640.        MessageBox (hWnd, "Invalid call handle", "", MB_OK);
  641.        break;
  642.     case LINEERR_INVALCALLSELECT:
  643.        MessageBox (hWnd, "Invalid call selection", "", MB_OK);
  644.        break;
  645.     case LINEERR_NODEVICE:
  646.        MessageBox (hWnd, "No associated device for given class",
  647.                    "", MB_OK);
  648.        break;
  649.     case LINEERR_OPERATIONUNAVAIL:
  650.        MessageBox (hWnd, "The operation is unavailable",
  651.                    "", MB_OK);
  652.        break;
  653.     case LINEERR_INVALPARAM:
  654.         MessageBox(hWnd, "Invalid Paramater", "", MB_OK);
  655.        break; 
  656.  
  657.     case LINEERR_TARGETNOTFOUND:
  658.         MessageBox(hWnd, "Target Not Found", "", MB_OK);
  659.        break; 
  660.  
  661.    case LINEERR_NOREQUEST:
  662.       MessageBox(hWnd, "No outstanding Assisted Telephony requests.", "", MB_OK);
  663.        break; 
  664.    }
  665. }
  666.  
  667. LRESULT CALLBACK Dial ( HWND hDlg,           // window handle of the dialog box
  668.                         UINT message,        // type of message
  669.                         WPARAM wParam,       // message-specific information
  670.                         LPARAM lParam)
  671. {
  672.    switch (message) 
  673.    {
  674.        case WM_INITDIALOG:  // message: initialize dialog box
  675.                return (TRUE);
  676.  
  677.        case WM_COMMAND:                              // message: received a command
  678.          if (   LOWORD(wParam) == IDOK )        // "OK" box selected?
  679.          {
  680.             GetDlgItemText(hDlg, IDC_NAME, szName, 128);
  681.                 GetDlgItemText(hDlg, IDC_NUMBER, szNumber, 128);
  682.                                       
  683.  
  684.                 // put up a dialog box to obtain a string to dial from the user
  685.                //...........................................................
  686.                strcpy(myCallInfo[0].szDialStringOriginal, szNumber); 
  687.                
  688.                //allocate buffer for the LINEADDRESSCAPS strucuture 
  689.                //...................................................
  690.                plineTranslateOutput = (LINETRANSLATEOUTPUT *) calloc (1, sizeof(LINETRANSLATEOUTPUT)+1000);
  691.             plineTranslateOutput->dwTotalSize = sizeof(LINETRANSLATEOUTPUT) + 1000;
  692.               
  693.                // translate the Address to a dialable address and Canonical address
  694.                //.....................................................................
  695.                lRet = lineTranslateAddress(myInfo.lineApp, myLineInfo[OWNER].dwLineID, myInfo.dwAPIVersion,
  696.                                            myCallInfo[0].szDialStringOriginal, 0, 0, plineTranslateOutput);
  697.                               
  698.                if (lRet == 0)
  699.                {
  700.                        
  701.                    strncpy(myCallInfo[0].szDialString, (LPSTR)(plineTranslateOutput)
  702.                             + plineTranslateOutput->dwDialableStringOffset,
  703.                              plineTranslateOutput->dwDialableStringSize); 
  704.     
  705.                     strncpy(myCallInfo[0].szDialStringCanonical,(LPSTR)(plineTranslateOutput) 
  706.                             + plineTranslateOutput->dwDisplayableStringOffset,
  707.                             plineTranslateOutput->dwDisplayableStringSize); 
  708.                                            
  709.                    myCallInfo[0].dwTranslateResults = plineTranslateOutput->dwTranslateResults;
  710.                 }
  711.  
  712.                else 
  713.                {
  714.                     wsprintf ( buf,"lineTranslateAddress failed, err=x%lx", lRet);
  715.                     lineError(lRet);
  716.                    break;
  717.             }
  718.            
  719.                //lineMakeCall
  720.                //................................................................
  721.                           
  722.                plineCallParams = (LINECALLPARAMS *) calloc (1, sizeof(LINECALLPARAMS)+1000);
  723.             plineCallParams->dwTotalSize = sizeof(LINECALLPARAMS) + 1000;
  724.  
  725.                plineCallParams->dwBearerMode = LINEBEARERMODE_VOICE;
  726.                plineCallParams->dwMediaMode =  LINEMEDIAMODE_DATAMODEM;
  727.                plineCallParams->dwCallParamFlags = LINECALLPARAMFLAGS_IDLE;
  728.                plineCallParams->dwAddressMode    = LINEADDRESSMODE_ADDRESSID;
  729.                plineCallParams->dwAddressID    = 0;
  730.                plineCallParams->dwMinRate    = 1200;
  731.                plineCallParams->dwMaxRate    = 2400;
  732.                             
  733.                lRet = lineMakeCall(myLineInfo[OWNER].hLine,&myCallInfo[0].hCall, 
  734.                                       myCallInfo[0].szDialString ,0,  plineCallParams);
  735.            
  736.             if (lRet > 0)
  737.                {
  738.                wsprintf (buf, "lineMakeCall suceeded!");
  739.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;               
  740.                    myCallInfo[0].dwRequestID = lRet;
  741.                 }
  742.             else 
  743.                {
  744.                    wsprintf ( buf,"lineMakeCall failed, err=x%lx", lRet);
  745.                     lineError(lRet);
  746.                    break;
  747.             }
  748.             
  749.             EndDialog(hDlg, TRUE);        // Exit the dialog
  750.             return (TRUE);
  751.          }
  752.  
  753.             if (   LOWORD(wParam) == IDCANCEL)         // "OK" box selected?
  754.          {
  755.             EndDialog(hDlg, TRUE);        // Exit the dialog
  756.             return (TRUE);
  757.          }
  758.          break;
  759.    }
  760.  
  761.    return (FALSE); 
  762. }
  763.  
  764.  
  765. LRESULT CALLBACK About( HWND hDlg,           
  766.                         UINT message,        
  767.                         WPARAM wParam,       
  768.                         LPARAM lParam)
  769. {
  770.    switch (message) 
  771.    {
  772.        case WM_INITDIALOG: 
  773.                return (TRUE);
  774.  
  775.        case WM_COMMAND:                              
  776.                if (   LOWORD(wParam) == IDOK         
  777.                    || LOWORD(wParam) == IDCANCEL)    
  778.                {
  779.                        EndDialog(hDlg, TRUE);        
  780.                        return (TRUE);
  781.                }
  782.                break;
  783.    }
  784.  
  785.    return (FALSE); 
  786. }
  787.  
  788.  
  789.